<%
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
bType=Request("bType")
%>
<!--#include file="..\CheckSession.inc"-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Tim kiem</title>
<body topmargin=0 leftmargin=0 bgcolor=#F8F9D9>
	<form name=frm method=post action="AddNguoiky.asp?bSearch=ok&bType=<%=bType%>">
		<table width=100% border=0>
			<tr>
				<td width=70%>
                <input name=Txt style="font-family:times new roman;width:100%" size="20"></td>
				<td width=30%><input name=Cmd value=Search Type=submit style="font-family:times new roman;width:100%"></td>
			</tr>
		</table>		
<%
			if request("bSearch")="ok" then	
				btxt=Request("Txt")
				sSQL="select hovaten from canbo where hovaten like '%"& replace(bTxt ,"'","''") &"%' and macanbo in(select macanbo from canbo_nhom where manhom in(select manhom from nhom where kyvanban=1)) order by stt1,stt2,stt3,ten,hovaten"
			else
				sSQL="select hovaten from canbo where macanbo in(select macanbo from canbo_nhom where manhom in(select manhom from nhom where kyvanban=1)) order by stt1,stt2,stt3,ten,hovaten"
			end if
			Set RecTC=Server.CreateObject("ADODB.Recordset")
			RecTC.CursorType=3
			RecTC.CacheSize=5
			RecTC.Open sSQL,Conn
%>
				<select  ondblclick="javaScript:doSelect()" size="8" name="List" style="font-family: times new roman; width: 100%; border-style: solid; border-width: 1; padding-left: 0; background-color: #FFFFFF; height:280" onkeyup="return List_onkeyup()">
<%
			Do While not RecTC.EOF
%>
		<option value="<%=trim(RecTC("hovaten"))%>"><%=trim(RecTC("hovaten"))%></option>
<%
				RecTC.movenext
			Loop
%>
		</select>
	</form>
</body>
<script language=javascript>
function doSelect() {
	var sValue;
	sValue = document.forms[0].List.value;
	<%
	Select case bType
		Case "DI"
	%>	
	if ("" + sValue != "") {
		window.close();
		if (window.opener) { 
			temp=window.opener.document.Noidung.TxtNguoiky.value;
			if  (temp!=""){
				temp=temp+"/ "
			}
			window.opener.document.Noidung.TxtNguoiky.value=temp+sValue; 			
			window.opener.document.Noidung.CmdNguoiky.focus();
		}
	}
	<% Case "QD" %>
	
	if ("" + sValue != "") {
		window.close();
		if (window.opener) { 
			temp=window.opener.document.Noidung.TxtNguoiky.value;
			if  (temp!=""){
				temp=temp+"/ "
			}
			window.opener.document.Noidung.TxtNguoiky.value=temp+sValue; 			
			window.opener.document.Noidung.CmdNguoiky.focus();
		}
	}

	<% Case "NB" %>
	
	if ("" + sValue != "") {
		window.close();
		if (window.opener) { 
			temp=window.opener.document.Noidung.TxtNguoitao.value;
			if  (temp!=""){
				temp=temp+"/ "
			}
			window.opener.document.Noidung.TxtNguoitao.value=temp+sValue; 			
			window.opener.document.Noidung.CmdNguoiky.focus();
		}
	}	
	<%
		End Select
	%>	
}	
function List_onkeyup(){
var keycode
keycode=window.event.keyCode
if (keycode==13) {
	doSelect();
}
}
    </script>